const app =getApp()
Page({
    data: {
        value : '' ,
        xData : [{
          writing_class_name:'疼痛日记',
          writing_class_number:'',
          icon:'./images/pain.png',
          des:'Pain diary',
          bgColor:'background-color:#D4EEE1'
        },{
          writing_class_name:'情绪日记',
          writing_class_number:'NO000001',
          icon:'./images/mood.png',
          des:'mood diary',
          bgColor:'background-color:#E0EFF5'
        }] ,
        week : 0 ,
    },

    onLoad : function (opt) {
        // this.xInit(opt.week)
        this.setData({
            week : opt.week
        })
    },
    onShareAppMessage: function () {
      return {
        title: '疼痛久治不愈？还有一招',
        path: '/subtool/pages/dayremb/index/index',
        imageUrl: 'https://7633-v3-92ah4-1300208657.tcb.qcloud.la/static/share_all.jpg',
      };
    },
    xInfo :function(){

    },
    xToWrite : function (e) {
      let that =this
      // if(app.globalData.product_buy){
        let id = e.currentTarget.dataset.id
        let num = e.currentTarget.dataset.num
        let title = e.currentTarget.dataset.title
        let week = this.data.week
        wx.navigateTo({
            url: '/subtool/pages/dayremb/detail/index?id=' + id + '&num=' + num + '&week='+week+'&title=' + title+'&day='+'&treatment_item_id=',
        })
      // }else{
      //   wx.showModal({
      //     title: "提示",
      //     content: "解锁完整版可使用该功能",
      //     confirmText:'去解锁',
      //     success (res) {
      //       if (res.confirm) {
      //         that.xToProduct()
      //       }
      //     }
      //   })
      // }
    },
    // 产品购买
    xToProduct:function(){
      let that =this
      if(!app.globalData.user.phone_number){
        let path = '/subsale/pages/product/index/index'
        let params = '&choose=true&id=26da8e4962b93a6000ec7c3d68d9d3eb'
        wx.navigateTo({
          url: '/pages/navigation/login/index?path='+path +params,
        })
      }else{
        wx.navigateTo({
          url: '/subsale/pages/product/index/index?choose=true&id=26da8e4962b93a6000ec7c3d68d9d3eb'
        })
      }
    },
    xToPain:function(){
      wx.navigateTo({
        url: '/subsale/pages/product/paindiary/index',
      })
    },
})